The present invention relates to a storage device having a semiconductor memory as a storage medium, particularly to a storage device using an error correction code for improving reliability of stored data.
Rapid increase in kinds and amounts of information data with the development of information processing equipment has brought a remarkable development of storing devices. For accelerating expansion of storage capacity, efforts have been directed to technological developments for increasing storage densities of storage media. Nevertheless, when data is stored in a temporary storage medium, namely in a rewritable storage medium, the security of the stored data is not always assured because phase change of magnetic material or storage of electrical charges is utilized. The reliability of stored data is generally lowered as the storage density is increased.
In a storage device with a flash memory, for example, electrical charges stored in a storage element sometimes gradually leaks out to cause destruction of data. Therefore, almost all storage devices of such a kind are provided with data protection functions using error correction codes. In an external storage device used for a personal computer, an error correction code, which is similar to the one used in a magnetic disk drive and calculated using 512 byte data, are stored together with data. When read out, the stored data are checked for errors, the errors are corrected if errors are detected, and then stored data are outputted with the security thereof being increased.
In the above conventional magnetic storage device, no problem is caused by stochastically occurred errors, namely, errors that do not reoccur in the same location. However, in the storage device, no consideration is given for errors fixed to a certain location due to accidents inherent to a storage medium such as fatigue, damage, foreign matter sticking, and wire breaking in the storage medium. If such kinds of errors occur with negligibly small probabilities, there is no problem. However, such kinds of errors will accumulate when they occur with probabilities that are not negligible in the normal use. The error correction code is usually capable of correcting errors with a specified number of bits or in a specified area. However, if there occurs errors exceeding error correction capability of the code, the error can not be detected (miss detection), or wrong identification of an error location or an error pattern can be made to perform faulty correction of correct data (miss correction). Therefore, even if data is corrected when being outputted, the incorrect data left uncorrected on the storage medium causes another error that accumulates to exceed the capability of the error correction code, which results in making it impossible to recover the stored data. Only with a measure for increasing reliability by merely using error correction code, the foregoing problem will occur.
In addition, there can be another problem due to occurrences of two kinds of errors characteristic to the storage medium: an occurrence of data error due to degradation of the medium and that due to accidental causes. In a nonvolatile semiconductor memory, for example, degradation due to repetition of a rewriting cycle deteriorates data maintain characteristics to cause data error. Meanwhile, electric signal noises or radiation can cause stochastic data errors irrespective of the degradation. In this case, by rereading the data, correct data can be sometimes read, or by rewriting the data, correct data can be read thereafter. However, these two kinds of data errors can not be distinguished from each other by observing the data which are the results of the errors. In the case of the data error due to degradation, since it will accumulate in a area as described above, a substitute area must be provided for storing data and the degraded area must be made unusable without being left as it is to avoid accumulation of errors. In the case of the data error which is accidental and does not relate to degradation, since an area with such error can be brought normal state by rewriting the data, providing a substitute area and making the error area unusable is to lower the efficiency of the storage device. However, no measure has been taken for such a problem as above.
It is an object of the present invention to increase security of the data in a nonvolatile semiconductor storage device and to extend life of the nonvolatile semiconductor storage device by deciding whether the occurred data error is of accident or of reoccurrence due to degradation and carrying out the suitable processing.
In a nonvolatile semiconductor storage device according to the present invention, first, when a data error is detected in reproducing data from each block of a storage medium, which block is a unit of data access, error correction is carried out with the error correction count recorded for each area. Second, it is judged for each block whether the error correction count reaches a predetermined value or not. If the error correction count is less than the predetermined value, corrected data is rewritten in the same area. If the error correction count has reached the predetermined value, a substitute area is allocated to which the corrected data is transferred with the previously used area made unusable.
Moreover, with the degree of error correction divided into a plurality of grades, rewriting the data or allotting a substitute area is selected to be executed in accordance with the grade.